{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">节点名称：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="title" value="" name="title" class="form-control" placeholder="请输入节点名称">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">节点值：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="val" value="" name="val" class="form-control" placeholder="请输入节点值">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">所属父类：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['pid'])){ $info['pid'] = ''; }; ?>
							<select lay-ignore name="pid" class="form-control" id="pid">
								<option value="">请选择</option>
								{sql query="select id,title,pid from cd_node"}
									<option value="{$sql.id}" {if condition="$info.pid eq $sql.id"}selected{/if}>{$sql.title}</option>
								{/sql}
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">排序：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="sortid" value="100" name="sortid" class="form-control" placeholder="请输入排序">
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = 1; }; ?>
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="开启">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="关闭">
						</div>
					</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否菜单：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['is_menu'])){ $info['is_menu'] = 0; }; ?>
							<input name="is_menu" value="1" type="radio" {if condition="$info.is_menu eq '1'"}checked{/if} title="开启">
							<input name="is_menu" value="0" type="radio" {if condition="$info.is_menu eq '0'"}checked{/if} title="关闭">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">icon图标：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="icon" value="" name="icon" class="form-control" placeholder="请输入icon图标">
							<span class="help-block m-b-none"><a  target="_blank" style="color:#ff0000" onclick="CodeInfoDlg.icon('menu_icon')">点击查看图标列表 </a></span>
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form'],function(){});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('id').set('title').set('val').set('pid').set('sortid').set('icon');
};

CodeInfoDlg.add = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	 var status = $("input[name = 'status']:checked").val();
	 var is_menu = $("input[name = 'is_menu']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/Node/add", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('status',status);
	 ajax.set('is_menu',is_menu);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};

CodeInfoDlg.icon = function () {
	var index = layer.open({type: 2,title: '设置图标',area: ['800px', '500px'],fix: false, maxmin: true,content: Feng.ctxPath + '/Base/icon/field/icon'});
	this.layerIndex = index;
}

</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
